<!doctype html>

<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>datepicker.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>


  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>

<div class="clear"></div>

<h2><a href="closure_goog_ui_datepicker.js.html">datepicker.js</a></h2>

<pre class="prettyprint lang-js">
<a name="line1"></a>// Copyright 2006 The Closure Library Authors. All Rights Reserved.
<a name="line2"></a>//
<a name="line3"></a>// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
<a name="line4"></a>// you may not use this file except in compliance with the License.
<a name="line5"></a>// You may obtain a copy of the License at
<a name="line6"></a>//
<a name="line7"></a>//      http://www.apache.org/licenses/LICENSE-2.0
<a name="line8"></a>//
<a name="line9"></a>// Unless required by applicable law or agreed to in writing, software
<a name="line10"></a>// distributed under the License is distributed on an &quot;AS-IS&quot; BASIS,
<a name="line11"></a>// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<a name="line12"></a>// See the License for the specific language governing permissions and
<a name="line13"></a>// limitations under the License.
<a name="line14"></a>
<a name="line15"></a>/**
<a name="line16"></a> * @fileoverview Date picker implementation.
<a name="line17"></a> *
<a name="line18"></a> * @author eae@google.com (Emil A Eklund)
<a name="line19"></a> * @see ../demos/datepicker.html
<a name="line20"></a> */
<a name="line21"></a>
<a name="line22"></a>goog.provide(&#39;goog.ui.DatePicker&#39;);
<a name="line23"></a>goog.provide(&#39;goog.ui.DatePicker.Events&#39;);
<a name="line24"></a>goog.provide(&#39;goog.ui.DatePickerEvent&#39;);
<a name="line25"></a>
<a name="line26"></a>goog.require(&#39;goog.a11y.aria&#39;);
<a name="line27"></a>goog.require(&#39;goog.asserts&#39;);
<a name="line28"></a>goog.require(&#39;goog.date&#39;);
<a name="line29"></a>goog.require(&#39;goog.date.Date&#39;);
<a name="line30"></a>goog.require(&#39;goog.date.Interval&#39;);
<a name="line31"></a>goog.require(&#39;goog.dom&#39;);
<a name="line32"></a>goog.require(&#39;goog.dom.classes&#39;);
<a name="line33"></a>goog.require(&#39;goog.events&#39;);
<a name="line34"></a>goog.require(&#39;goog.events.Event&#39;);
<a name="line35"></a>goog.require(&#39;goog.events.EventType&#39;);
<a name="line36"></a>goog.require(&#39;goog.events.KeyHandler&#39;);
<a name="line37"></a>goog.require(&#39;goog.events.KeyHandler.EventType&#39;);
<a name="line38"></a>goog.require(&#39;goog.i18n.DateTimeFormat&#39;);
<a name="line39"></a>goog.require(&#39;goog.i18n.DateTimeSymbols&#39;);
<a name="line40"></a>goog.require(&#39;goog.style&#39;);
<a name="line41"></a>goog.require(&#39;goog.ui.Component&#39;);
<a name="line42"></a>goog.require(&#39;goog.ui.IdGenerator&#39;);
<a name="line43"></a>
<a name="line44"></a>
<a name="line45"></a>
<a name="line46"></a>/**
<a name="line47"></a> * DatePicker widget. Allows a single date to be selected from a calendar like
<a name="line48"></a> * view.
<a name="line49"></a> *
<a name="line50"></a> * @param {goog.date.Date|Date=} opt_date Date to initialize the date picker
<a name="line51"></a> *     with, defaults to the current date.
<a name="line52"></a> * @param {Object=} opt_dateTimeSymbols Date and time symbols to use.
<a name="line53"></a> *     Defaults to goog.i18n.DateTimeSymbols if not set.
<a name="line54"></a> * @param {goog.dom.DomHelper=} opt_domHelper Optional DOM helper.
<a name="line55"></a> * @constructor
<a name="line56"></a> * @extends {goog.ui.Component}
<a name="line57"></a> */
<a name="line58"></a>goog.ui.DatePicker = function(opt_date, opt_dateTimeSymbols, opt_domHelper) {
<a name="line59"></a>  goog.ui.Component.call(this, opt_domHelper);
<a name="line60"></a>
<a name="line61"></a>  /**
<a name="line62"></a>   * Date and time symbols to use.
<a name="line63"></a>   * @type {Object}
<a name="line64"></a>   * @private
<a name="line65"></a>   */
<a name="line66"></a>  this.symbols_ = opt_dateTimeSymbols || goog.i18n.DateTimeSymbols;
<a name="line67"></a>
<a name="line68"></a>  this.wdayNames_ = this.symbols_.SHORTWEEKDAYS;
<a name="line69"></a>
<a name="line70"></a>  /**
<a name="line71"></a>   * Selected date.
<a name="line72"></a>   * @type {goog.date.Date}
<a name="line73"></a>   * @private
<a name="line74"></a>   */
<a name="line75"></a>  this.date_ = new goog.date.Date(opt_date);
<a name="line76"></a>  this.date_.setFirstWeekCutOffDay(this.symbols_.FIRSTWEEKCUTOFFDAY);
<a name="line77"></a>  this.date_.setFirstDayOfWeek(this.symbols_.FIRSTDAYOFWEEK);
<a name="line78"></a>
<a name="line79"></a>  /**
<a name="line80"></a>   * Active month.
<a name="line81"></a>   * @type {goog.date.Date}
<a name="line82"></a>   * @private
<a name="line83"></a>   */
<a name="line84"></a>  this.activeMonth_ = this.date_.clone();
<a name="line85"></a>  this.activeMonth_.setDate(1);
<a name="line86"></a>
<a name="line87"></a>  /**
<a name="line88"></a>   * Class names to apply to the weekday columns.
<a name="line89"></a>   * @type {Array.&lt;string&gt;}
<a name="line90"></a>   * @private
<a name="line91"></a>   */
<a name="line92"></a>  this.wdayStyles_ = [&#39;&#39;, &#39;&#39;, &#39;&#39;, &#39;&#39;, &#39;&#39;, &#39;&#39;, &#39;&#39;];
<a name="line93"></a>  this.wdayStyles_[this.symbols_.WEEKENDRANGE[0]] =
<a name="line94"></a>      goog.getCssName(this.getBaseCssClass(), &#39;wkend-start&#39;);
<a name="line95"></a>  this.wdayStyles_[this.symbols_.WEEKENDRANGE[1]] =
<a name="line96"></a>      goog.getCssName(this.getBaseCssClass(), &#39;wkend-end&#39;);
<a name="line97"></a>
<a name="line98"></a>  /**
<a name="line99"></a>   * Object that is being used to cache key handlers.
<a name="line100"></a>   * @type {Object}
<a name="line101"></a>   * @private
<a name="line102"></a>   */
<a name="line103"></a>  this.keyHandlers_ = {};
<a name="line104"></a>};
<a name="line105"></a>goog.inherits(goog.ui.DatePicker, goog.ui.Component);
<a name="line106"></a>
<a name="line107"></a>
<a name="line108"></a>/**
<a name="line109"></a> * Flag indicating if the number of weeks shown should be fixed.
<a name="line110"></a> * @type {boolean}
<a name="line111"></a> * @private
<a name="line112"></a> */
<a name="line113"></a>goog.ui.DatePicker.prototype.showFixedNumWeeks_ = true;
<a name="line114"></a>
<a name="line115"></a>
<a name="line116"></a>/**
<a name="line117"></a> * Flag indicating if days from other months should be shown.
<a name="line118"></a> * @type {boolean}
<a name="line119"></a> * @private
<a name="line120"></a> */
<a name="line121"></a>goog.ui.DatePicker.prototype.showOtherMonths_ = true;
<a name="line122"></a>
<a name="line123"></a>
<a name="line124"></a>/**
<a name="line125"></a> * Flag indicating if extra week(s) always should be added at the end. If not
<a name="line126"></a> * set the extra week is added at the beginning if the number of days shown
<a name="line127"></a> * from the previous month is less then the number from the next month.
<a name="line128"></a> * @type {boolean}
<a name="line129"></a> * @private
<a name="line130"></a> */
<a name="line131"></a>goog.ui.DatePicker.prototype.extraWeekAtEnd_ = true;
<a name="line132"></a>
<a name="line133"></a>
<a name="line134"></a>/**
<a name="line135"></a> * Flag indicating if week numbers should be shown.
<a name="line136"></a> * @type {boolean}
<a name="line137"></a> * @private
<a name="line138"></a> */
<a name="line139"></a>goog.ui.DatePicker.prototype.showWeekNum_ = true;
<a name="line140"></a>
<a name="line141"></a>
<a name="line142"></a>/**
<a name="line143"></a> * Flag indicating if weekday names should be shown.
<a name="line144"></a> * @type {boolean}
<a name="line145"></a> * @private
<a name="line146"></a> */
<a name="line147"></a>goog.ui.DatePicker.prototype.showWeekdays_ = true;
<a name="line148"></a>
<a name="line149"></a>
<a name="line150"></a>/**
<a name="line151"></a> * Flag indicating if none is a valid selection. Also controls if the none
<a name="line152"></a> * button should be shown or not.
<a name="line153"></a> * @type {boolean}
<a name="line154"></a> * @private
<a name="line155"></a> */
<a name="line156"></a>goog.ui.DatePicker.prototype.allowNone_ = true;
<a name="line157"></a>
<a name="line158"></a>
<a name="line159"></a>/**
<a name="line160"></a> * Flag indicating if the today button should be shown.
<a name="line161"></a> * @type {boolean}
<a name="line162"></a> * @private
<a name="line163"></a> */
<a name="line164"></a>goog.ui.DatePicker.prototype.showToday_ = true;
<a name="line165"></a>
<a name="line166"></a>
<a name="line167"></a>/**
<a name="line168"></a> * Flag indicating if the picker should use a simple navigation menu that only
<a name="line169"></a> * contains controls for navigating to the next and previous month. The default
<a name="line170"></a> * navigation menu contains controls for navigating to the next/previous month,
<a name="line171"></a> * next/previous year, and menus for jumping to specific months and years.
<a name="line172"></a> * @type {boolean}
<a name="line173"></a> * @private
<a name="line174"></a> */
<a name="line175"></a>goog.ui.DatePicker.prototype.simpleNavigation_ = false;
<a name="line176"></a>
<a name="line177"></a>
<a name="line178"></a>/**
<a name="line179"></a> * Custom decorator function. Takes a goog.date.Date object, returns a String
<a name="line180"></a> * representing a CSS class or null if no special styling applies
<a name="line181"></a> * @type {Function}
<a name="line182"></a> * @private
<a name="line183"></a> */
<a name="line184"></a>goog.ui.DatePicker.prototype.decoratorFunction_ = null;
<a name="line185"></a>
<a name="line186"></a>
<a name="line187"></a>/**
<a name="line188"></a> * Element for navigation row on a datepicker.
<a name="line189"></a> * @type {Element}
<a name="line190"></a> * @private
<a name="line191"></a> */
<a name="line192"></a>goog.ui.DatePicker.prototype.elNavRow_ = null;
<a name="line193"></a>
<a name="line194"></a>
<a name="line195"></a>/**
<a name="line196"></a> * Element for footer row on a datepicker.
<a name="line197"></a> * @type {Element}
<a name="line198"></a> * @private
<a name="line199"></a> */
<a name="line200"></a>goog.ui.DatePicker.prototype.elFootRow_ = null;
<a name="line201"></a>
<a name="line202"></a>
<a name="line203"></a>/**
<a name="line204"></a> * Generator for unique table cell IDs.
<a name="line205"></a> * @type {goog.ui.IdGenerator}
<a name="line206"></a> * @private
<a name="line207"></a> */
<a name="line208"></a>goog.ui.DatePicker.prototype.cellIdGenerator_ =
<a name="line209"></a>    goog.ui.IdGenerator.getInstance();
<a name="line210"></a>
<a name="line211"></a>
<a name="line212"></a>/**
<a name="line213"></a> * Name of base CSS clase of datepicker.
<a name="line214"></a> * @type {string}
<a name="line215"></a> * @private
<a name="line216"></a> */
<a name="line217"></a>goog.ui.DatePicker.BASE_CSS_CLASS_ = goog.getCssName(&#39;goog-date-picker&#39;);
<a name="line218"></a>
<a name="line219"></a>
<a name="line220"></a>/**
<a name="line221"></a> * Constants for event names
<a name="line222"></a> *
<a name="line223"></a> * @type {Object}
<a name="line224"></a> */
<a name="line225"></a>goog.ui.DatePicker.Events = {
<a name="line226"></a>  CHANGE: &#39;change&#39;,
<a name="line227"></a>  SELECT: &#39;select&#39;
<a name="line228"></a>};
<a name="line229"></a>
<a name="line230"></a>
<a name="line231"></a>/**
<a name="line232"></a> * @deprecated Use isInDocument.
<a name="line233"></a> */
<a name="line234"></a>goog.ui.DatePicker.prototype.isCreated =
<a name="line235"></a>    goog.ui.DatePicker.prototype.isInDocument;
<a name="line236"></a>
<a name="line237"></a>
<a name="line238"></a>/**
<a name="line239"></a> * @return {number} The first day of week, 0 = Monday, 6 = Sunday.
<a name="line240"></a> */
<a name="line241"></a>goog.ui.DatePicker.prototype.getFirstWeekday = function() {
<a name="line242"></a>  return this.activeMonth_.getFirstDayOfWeek();
<a name="line243"></a>};
<a name="line244"></a>
<a name="line245"></a>
<a name="line246"></a>/**
<a name="line247"></a> * Returns the class name associated with specified weekday.
<a name="line248"></a> * @param {number} wday The week day number to get the class name for.
<a name="line249"></a> * @return {string} The class name associated with specified weekday.
<a name="line250"></a> */
<a name="line251"></a>goog.ui.DatePicker.prototype.getWeekdayClass = function(wday) {
<a name="line252"></a>  return this.wdayStyles_[wday];
<a name="line253"></a>};
<a name="line254"></a>
<a name="line255"></a>
<a name="line256"></a>/**
<a name="line257"></a> * @return {boolean} Whether a fixed number of weeks should be showed. If not
<a name="line258"></a> *     only weeks for the current month will be shown.
<a name="line259"></a> */
<a name="line260"></a>goog.ui.DatePicker.prototype.getShowFixedNumWeeks = function() {
<a name="line261"></a>  return this.showFixedNumWeeks_;
<a name="line262"></a>};
<a name="line263"></a>
<a name="line264"></a>
<a name="line265"></a>/**
<a name="line266"></a> * @return {boolean} Whether a days from the previous and/or next month should
<a name="line267"></a> *     be shown.
<a name="line268"></a> */
<a name="line269"></a>goog.ui.DatePicker.prototype.getShowOtherMonths = function() {
<a name="line270"></a>  return this.showOtherMonths_;
<a name="line271"></a>};
<a name="line272"></a>
<a name="line273"></a>
<a name="line274"></a>/**
<a name="line275"></a> * @return {boolean} Whether a the extra week(s) added always should be at the
<a name="line276"></a> *     end. Only applicable if a fixed number of weeks are shown.
<a name="line277"></a> */
<a name="line278"></a>goog.ui.DatePicker.prototype.getExtraWeekAtEnd = function() {
<a name="line279"></a>  return this.extraWeekAtEnd_;
<a name="line280"></a>};
<a name="line281"></a>
<a name="line282"></a>
<a name="line283"></a>/**
<a name="line284"></a> * @return {boolean} Whether week numbers should be shown.
<a name="line285"></a> */
<a name="line286"></a>goog.ui.DatePicker.prototype.getShowWeekNum = function() {
<a name="line287"></a>  return this.showWeekNum_;
<a name="line288"></a>};
<a name="line289"></a>
<a name="line290"></a>
<a name="line291"></a>/**
<a name="line292"></a> * @return {boolean} Whether weekday names should be shown.
<a name="line293"></a> */
<a name="line294"></a>goog.ui.DatePicker.prototype.getShowWeekdayNames = function() {
<a name="line295"></a>  return this.showWeekdays_;
<a name="line296"></a>};
<a name="line297"></a>
<a name="line298"></a>
<a name="line299"></a>/**
<a name="line300"></a> * @return {boolean} Whether none is a valid selection.
<a name="line301"></a> */
<a name="line302"></a>goog.ui.DatePicker.prototype.getAllowNone = function() {
<a name="line303"></a>  return this.allowNone_;
<a name="line304"></a>};
<a name="line305"></a>
<a name="line306"></a>
<a name="line307"></a>/**
<a name="line308"></a> * @return {boolean} Whether the today button should be shown.
<a name="line309"></a> */
<a name="line310"></a>goog.ui.DatePicker.prototype.getShowToday = function() {
<a name="line311"></a>  return this.showToday_;
<a name="line312"></a>};
<a name="line313"></a>
<a name="line314"></a>
<a name="line315"></a>/**
<a name="line316"></a> * Returns base CSS class. This getter is used to get base CSS class part.
<a name="line317"></a> * All CSS class names in component are created as:
<a name="line318"></a> *   goog.getCssName(this.getBaseCssClass(), &#39;CLASS_NAME&#39;)
<a name="line319"></a> * @return {string} Base CSS class.
<a name="line320"></a> */
<a name="line321"></a>goog.ui.DatePicker.prototype.getBaseCssClass = function() {
<a name="line322"></a>  return goog.ui.DatePicker.BASE_CSS_CLASS_;
<a name="line323"></a>};
<a name="line324"></a>
<a name="line325"></a>
<a name="line326"></a>/**
<a name="line327"></a> * Sets the first day of week
<a name="line328"></a> *
<a name="line329"></a> * @param {number} wday Week day, 0 = Monday, 6 = Sunday.
<a name="line330"></a> */
<a name="line331"></a>goog.ui.DatePicker.prototype.setFirstWeekday = function(wday) {
<a name="line332"></a>  this.activeMonth_.setFirstDayOfWeek(wday);
<a name="line333"></a>  this.updateCalendarGrid_();
<a name="line334"></a>  this.redrawWeekdays_();
<a name="line335"></a>};
<a name="line336"></a>
<a name="line337"></a>
<a name="line338"></a>/**
<a name="line339"></a> * Sets class name associated with specified weekday.
<a name="line340"></a> *
<a name="line341"></a> * @param {number} wday Week day, 0 = Monday, 6 = Sunday.
<a name="line342"></a> * @param {string} className Class name.
<a name="line343"></a> */
<a name="line344"></a>goog.ui.DatePicker.prototype.setWeekdayClass = function(wday, className) {
<a name="line345"></a>  this.wdayStyles_[wday] = className;
<a name="line346"></a>  this.redrawCalendarGrid_();
<a name="line347"></a>};
<a name="line348"></a>
<a name="line349"></a>
<a name="line350"></a>/**
<a name="line351"></a> * Sets whether a fixed number of weeks should be showed. If not only weeks
<a name="line352"></a> * for the current month will be showed.
<a name="line353"></a> *
<a name="line354"></a> * @param {boolean} b Whether a fixed number of weeks should be showed.
<a name="line355"></a> */
<a name="line356"></a>goog.ui.DatePicker.prototype.setShowFixedNumWeeks = function(b) {
<a name="line357"></a>  this.showFixedNumWeeks_ = b;
<a name="line358"></a>  this.updateCalendarGrid_();
<a name="line359"></a>};
<a name="line360"></a>
<a name="line361"></a>
<a name="line362"></a>/**
<a name="line363"></a> * Sets whether a days from the previous and/or next month should be shown.
<a name="line364"></a> *
<a name="line365"></a> * @param {boolean} b Whether a days from the previous and/or next month should
<a name="line366"></a> *     be shown.
<a name="line367"></a> */
<a name="line368"></a>goog.ui.DatePicker.prototype.setShowOtherMonths = function(b) {
<a name="line369"></a>  this.showOtherMonths_ = b;
<a name="line370"></a>  this.redrawCalendarGrid_();
<a name="line371"></a>};
<a name="line372"></a>
<a name="line373"></a>
<a name="line374"></a>/**
<a name="line375"></a> * Sets whether the picker should use a simple navigation menu that only
<a name="line376"></a> * contains controls for navigating to the next and previous month. The default
<a name="line377"></a> * navigation menu contains controls for navigating to the next/previous month,
<a name="line378"></a> * next/previous year, and menus for jumping to specific months and years.
<a name="line379"></a> *
<a name="line380"></a> * @param {boolean} b Whether to use a simple navigation menu.
<a name="line381"></a> */
<a name="line382"></a>goog.ui.DatePicker.prototype.setUseSimpleNavigationMenu = function(b) {
<a name="line383"></a>  this.simpleNavigation_ = b;
<a name="line384"></a>  this.updateNavigationRow_();
<a name="line385"></a>  this.updateCalendarGrid_();
<a name="line386"></a>};
<a name="line387"></a>
<a name="line388"></a>
<a name="line389"></a>/**
<a name="line390"></a> * Sets whether a the extra week(s) added always should be at the end. Only
<a name="line391"></a> * applicable if a fixed number of weeks are shown.
<a name="line392"></a> *
<a name="line393"></a> * @param {boolean} b Whether a the extra week(s) added always should be at the
<a name="line394"></a> *     end.
<a name="line395"></a> */
<a name="line396"></a>goog.ui.DatePicker.prototype.setExtraWeekAtEnd = function(b) {
<a name="line397"></a>  this.extraWeekAtEnd_ = b;
<a name="line398"></a>  this.updateCalendarGrid_();
<a name="line399"></a>};
<a name="line400"></a>
<a name="line401"></a>
<a name="line402"></a>/**
<a name="line403"></a> * Sets whether week numbers should be shown.
<a name="line404"></a> *
<a name="line405"></a> * @param {boolean} b Whether week numbers should be shown.
<a name="line406"></a> */
<a name="line407"></a>goog.ui.DatePicker.prototype.setShowWeekNum = function(b) {
<a name="line408"></a>  this.showWeekNum_ = b;
<a name="line409"></a>  // The navigation row may rely on the number of visible columns,
<a name="line410"></a>  // so we update it when adding/removing the weeknum column.
<a name="line411"></a>  this.updateNavigationRow_();
<a name="line412"></a>  this.updateCalendarGrid_();
<a name="line413"></a>};
<a name="line414"></a>
<a name="line415"></a>
<a name="line416"></a>/**
<a name="line417"></a> * Sets whether weekday names should be shown.
<a name="line418"></a> *
<a name="line419"></a> * @param {boolean} b Whether weekday names should be shown.
<a name="line420"></a> */
<a name="line421"></a>goog.ui.DatePicker.prototype.setShowWeekdayNames = function(b) {
<a name="line422"></a>  this.showWeekdays_ = b;
<a name="line423"></a>  this.redrawCalendarGrid_();
<a name="line424"></a>};
<a name="line425"></a>
<a name="line426"></a>
<a name="line427"></a>/**
<a name="line428"></a> * Sets whether the picker uses narrow weekday names (&#39;M&#39;, &#39;T&#39;, &#39;W&#39;, ...).
<a name="line429"></a> *
<a name="line430"></a> * The default behavior is to use short names (&#39;Mon&#39;, &#39;Tue&#39;, &#39;Wed&#39;, ...).
<a name="line431"></a> *
<a name="line432"></a> * @param {boolean} b Whether to use narrow weekday names.
<a name="line433"></a> */
<a name="line434"></a>goog.ui.DatePicker.prototype.setUseNarrowWeekdayNames = function(b) {
<a name="line435"></a>  this.wdayNames_ = b ? this.symbols_.NARROWWEEKDAYS :
<a name="line436"></a>      this.symbols_.SHORTWEEKDAYS;
<a name="line437"></a>  this.redrawWeekdays_();
<a name="line438"></a>};
<a name="line439"></a>
<a name="line440"></a>
<a name="line441"></a>/**
<a name="line442"></a> * Sets whether none is a valid selection.
<a name="line443"></a> *
<a name="line444"></a> * @param {boolean} b Whether none is a valid selection.
<a name="line445"></a> */
<a name="line446"></a>goog.ui.DatePicker.prototype.setAllowNone = function(b) {
<a name="line447"></a>  this.allowNone_ = b;
<a name="line448"></a>  if (this.elNone_) {
<a name="line449"></a>    this.updateTodayAndNone_();
<a name="line450"></a>  }
<a name="line451"></a>};
<a name="line452"></a>
<a name="line453"></a>
<a name="line454"></a>/**
<a name="line455"></a> * Sets whether the today button should be shown.
<a name="line456"></a> *
<a name="line457"></a> * @param {boolean} b Whether the today button should be shown.
<a name="line458"></a> */
<a name="line459"></a>goog.ui.DatePicker.prototype.setShowToday = function(b) {
<a name="line460"></a>  this.showToday_ = b;
<a name="line461"></a>  if (this.elToday_) {
<a name="line462"></a>    this.updateTodayAndNone_();
<a name="line463"></a>  }
<a name="line464"></a>};
<a name="line465"></a>
<a name="line466"></a>
<a name="line467"></a>/**
<a name="line468"></a> * Updates the display style of the None and Today buttons as well as hides the
<a name="line469"></a> * table foot if both are hidden.
<a name="line470"></a> * @private
<a name="line471"></a> */
<a name="line472"></a>goog.ui.DatePicker.prototype.updateTodayAndNone_ = function() {
<a name="line473"></a>  goog.style.showElement(this.elToday_, this.showToday_);
<a name="line474"></a>  goog.style.showElement(this.elNone_, this.allowNone_);
<a name="line475"></a>  goog.style.showElement(this.tableFoot_, this.showToday_ || this.allowNone_);
<a name="line476"></a>};
<a name="line477"></a>
<a name="line478"></a>
<a name="line479"></a>/**
<a name="line480"></a> * Sets the decorator function. The function should have the interface of
<a name="line481"></a> *   {string} f({goog.date.Date});
<a name="line482"></a> * and return a String representing a CSS class to decorate the cell
<a name="line483"></a> * corresponding to the date specified.
<a name="line484"></a> *
<a name="line485"></a> * @param {Function} f The decorator function.
<a name="line486"></a> */
<a name="line487"></a>goog.ui.DatePicker.prototype.setDecorator = function(f) {
<a name="line488"></a>  this.decoratorFunction_ = f;
<a name="line489"></a>};
<a name="line490"></a>
<a name="line491"></a>
<a name="line492"></a>/**
<a name="line493"></a> * Changes the active month to the previous one.
<a name="line494"></a> */
<a name="line495"></a>goog.ui.DatePicker.prototype.previousMonth = function() {
<a name="line496"></a>  this.activeMonth_.add(new goog.date.Interval(goog.date.Interval.MONTHS, -1));
<a name="line497"></a>  this.updateCalendarGrid_();
<a name="line498"></a>};
<a name="line499"></a>
<a name="line500"></a>
<a name="line501"></a>/**
<a name="line502"></a> * Changes the active month to the next one.
<a name="line503"></a> */
<a name="line504"></a>goog.ui.DatePicker.prototype.nextMonth = function() {
<a name="line505"></a>  this.activeMonth_.add(new goog.date.Interval(goog.date.Interval.MONTHS, 1));
<a name="line506"></a>  this.updateCalendarGrid_();
<a name="line507"></a>};
<a name="line508"></a>
<a name="line509"></a>
<a name="line510"></a>/**
<a name="line511"></a> * Changes the active year to the previous one.
<a name="line512"></a> */
<a name="line513"></a>goog.ui.DatePicker.prototype.previousYear = function() {
<a name="line514"></a>  this.activeMonth_.add(new goog.date.Interval(goog.date.Interval.YEARS, -1));
<a name="line515"></a>  this.updateCalendarGrid_();
<a name="line516"></a>};
<a name="line517"></a>
<a name="line518"></a>
<a name="line519"></a>/**
<a name="line520"></a> * Changes the active year to the next one.
<a name="line521"></a> */
<a name="line522"></a>goog.ui.DatePicker.prototype.nextYear = function() {
<a name="line523"></a>  this.activeMonth_.add(new goog.date.Interval(goog.date.Interval.YEARS, 1));
<a name="line524"></a>  this.updateCalendarGrid_();
<a name="line525"></a>};
<a name="line526"></a>
<a name="line527"></a>
<a name="line528"></a>/**
<a name="line529"></a> * Selects the current date.
<a name="line530"></a> */
<a name="line531"></a>goog.ui.DatePicker.prototype.selectToday = function() {
<a name="line532"></a>  this.setDate(new goog.date.Date());
<a name="line533"></a>};
<a name="line534"></a>
<a name="line535"></a>
<a name="line536"></a>/**
<a name="line537"></a> * Clears the selection.
<a name="line538"></a> */
<a name="line539"></a>goog.ui.DatePicker.prototype.selectNone = function() {
<a name="line540"></a>  if (this.allowNone_) {
<a name="line541"></a>    this.setDate(null);
<a name="line542"></a>  }
<a name="line543"></a>};
<a name="line544"></a>
<a name="line545"></a>
<a name="line546"></a>/**
<a name="line547"></a> * @return {goog.date.Date} The active month displayed.
<a name="line548"></a> */
<a name="line549"></a>goog.ui.DatePicker.prototype.getActiveMonth = function() {
<a name="line550"></a>  return this.activeMonth_.clone();
<a name="line551"></a>};
<a name="line552"></a>
<a name="line553"></a>
<a name="line554"></a>/**
<a name="line555"></a> * @return {goog.date.Date} The selected date or null if nothing is selected.
<a name="line556"></a> */
<a name="line557"></a>goog.ui.DatePicker.prototype.getDate = function() {
<a name="line558"></a>  return this.date_ &amp;&amp; this.date_.clone();
<a name="line559"></a>};
<a name="line560"></a>
<a name="line561"></a>
<a name="line562"></a>/**
<a name="line563"></a> * Sets the selected date.
<a name="line564"></a> *
<a name="line565"></a> * @param {goog.date.Date|Date} date Date to select or null to select nothing.
<a name="line566"></a> */
<a name="line567"></a>goog.ui.DatePicker.prototype.setDate = function(date) {
<a name="line568"></a>  // Check if date has been changed
<a name="line569"></a>  var changed = date != this.date_ &amp;&amp;
<a name="line570"></a>      !(date &amp;&amp; this.date_ &amp;&amp;
<a name="line571"></a>        date.getFullYear() == this.date_.getFullYear() &amp;&amp;
<a name="line572"></a>        date.getMonth() == this.date_.getMonth() &amp;&amp;
<a name="line573"></a>        date.getDate() == this.date_.getDate());
<a name="line574"></a>
<a name="line575"></a>  // Set current date to clone of supplied goog.date.Date or Date.
<a name="line576"></a>  this.date_ = date &amp;&amp; new goog.date.Date(date);
<a name="line577"></a>
<a name="line578"></a>  // Set current month
<a name="line579"></a>  if (date) {
<a name="line580"></a>    this.activeMonth_.set(this.date_);
<a name="line581"></a>    this.activeMonth_.setDate(1);
<a name="line582"></a>  }
<a name="line583"></a>
<a name="line584"></a>  // Update calendar grid even if the date has not changed as even if today is
<a name="line585"></a>  // selected another month can be displayed.
<a name="line586"></a>  this.updateCalendarGrid_();
<a name="line587"></a>
<a name="line588"></a>  // TODO(eae): Standardize selection and change events with other components.
<a name="line589"></a>  // Fire select event.
<a name="line590"></a>  var selectEvent = new goog.ui.DatePickerEvent(
<a name="line591"></a>      goog.ui.DatePicker.Events.SELECT, this, this.date_);
<a name="line592"></a>  this.dispatchEvent(selectEvent);
<a name="line593"></a>
<a name="line594"></a>  // Fire change event.
<a name="line595"></a>  if (changed) {
<a name="line596"></a>    var changeEvent = new goog.ui.DatePickerEvent(
<a name="line597"></a>        goog.ui.DatePicker.Events.CHANGE, this, this.date_);
<a name="line598"></a>    this.dispatchEvent(changeEvent);
<a name="line599"></a>  }
<a name="line600"></a>};
<a name="line601"></a>
<a name="line602"></a>
<a name="line603"></a>/**
<a name="line604"></a> * Updates the navigation row (navigating months and maybe years) in the navRow_
<a name="line605"></a> * element of a created picker.
<a name="line606"></a> * @private
<a name="line607"></a> */
<a name="line608"></a>goog.ui.DatePicker.prototype.updateNavigationRow_ = function() {
<a name="line609"></a>  if (!this.elNavRow_) {
<a name="line610"></a>    return;
<a name="line611"></a>  }
<a name="line612"></a>  var row = this.elNavRow_;
<a name="line613"></a>
<a name="line614"></a>  // Clear the navigation row.
<a name="line615"></a>  while (row.firstChild) {
<a name="line616"></a>    row.removeChild(row.firstChild);
<a name="line617"></a>  }
<a name="line618"></a>  // Populate the navigation row according to the configured navigation mode.
<a name="line619"></a>  var cell, monthCell, yearCell;
<a name="line620"></a>
<a name="line621"></a>  if (this.simpleNavigation_) {
<a name="line622"></a>    cell = this.dom_.createElement(&#39;td&#39;);
<a name="line623"></a>    cell.colSpan = this.showWeekNum_ ? 1 : 2;
<a name="line624"></a>    this.createButton_(cell, &#39;\u00AB&#39;, this.previousMonth);  // &lt;&lt;
<a name="line625"></a>    row.appendChild(cell);
<a name="line626"></a>
<a name="line627"></a>    cell = this.dom_.createElement(&#39;td&#39;);
<a name="line628"></a>    cell.colSpan = this.showWeekNum_ ? 6 : 5;
<a name="line629"></a>    cell.className = goog.getCssName(this.getBaseCssClass(), &#39;monthyear&#39;);
<a name="line630"></a>    row.appendChild(cell);
<a name="line631"></a>    this.elMonthYear_ = cell;
<a name="line632"></a>
<a name="line633"></a>    cell = this.dom_.createElement(&#39;td&#39;);
<a name="line634"></a>    this.createButton_(cell, &#39;\u00BB&#39;, this.nextMonth);  // &gt;&gt;
<a name="line635"></a>    row.appendChild(cell);
<a name="line636"></a>
<a name="line637"></a>  } else {
<a name="line638"></a>    var fullDateFormat = this.symbols_.DATEFORMATS[
<a name="line639"></a>        goog.i18n.DateTimeFormat.Format.FULL_DATE].toLowerCase();
<a name="line640"></a>
<a name="line641"></a>    monthCell = this.dom_.createElement(&#39;td&#39;);
<a name="line642"></a>    monthCell.colSpan = 5;
<a name="line643"></a>    this.createButton_(monthCell, &#39;\u00AB&#39;, this.previousMonth);  // &lt;&lt;
<a name="line644"></a>    this.elMonth_ = this.createButton_(
<a name="line645"></a>        monthCell, &#39;&#39;, this.showMonthMenu_,
<a name="line646"></a>        goog.getCssName(this.getBaseCssClass(), &#39;month&#39;));
<a name="line647"></a>    this.createButton_(monthCell, &#39;\u00BB&#39;, this.nextMonth);  // &gt;&gt;
<a name="line648"></a>
<a name="line649"></a>    yearCell = this.dom_.createElement(&#39;td&#39;);
<a name="line650"></a>    yearCell.colSpan = 3;
<a name="line651"></a>    this.createButton_(yearCell, &#39;\u00AB&#39;, this.previousYear);  // &lt;&lt;
<a name="line652"></a>    this.elYear_ = this.createButton_(yearCell, &#39;&#39;, this.showYearMenu_,
<a name="line653"></a>                                      goog.getCssName(this.getBaseCssClass(),
<a name="line654"></a>                                                      &#39;year&#39;));
<a name="line655"></a>    this.createButton_(yearCell, &#39;\u00BB&#39;, this.nextYear);  // &gt;&gt;
<a name="line656"></a>
<a name="line657"></a>    // If the date format has year (&#39;y&#39;) appearing first before month (&#39;m&#39;),
<a name="line658"></a>    // show the year on the left hand side of the datepicker popup.  Otherwise,
<a name="line659"></a>    // show the month on the left side.  This check assumes the data to be
<a name="line660"></a>    // valid, and that all date formats contain month and year.
<a name="line661"></a>    if (fullDateFormat.indexOf(&#39;y&#39;) &lt; fullDateFormat.indexOf(&#39;m&#39;)) {
<a name="line662"></a>      row.appendChild(yearCell);
<a name="line663"></a>      row.appendChild(monthCell);
<a name="line664"></a>    } else {
<a name="line665"></a>      row.appendChild(monthCell);
<a name="line666"></a>      row.appendChild(yearCell);
<a name="line667"></a>    }
<a name="line668"></a>  }
<a name="line669"></a>};
<a name="line670"></a>
<a name="line671"></a>
<a name="line672"></a>/**
<a name="line673"></a> * Updates the footer row (with select buttons) in the footRow_ element of a
<a name="line674"></a> * created picker.
<a name="line675"></a> * @private
<a name="line676"></a> */
<a name="line677"></a>goog.ui.DatePicker.prototype.updateFooterRow_ = function() {
<a name="line678"></a>  var row = this.elFootRow_;
<a name="line679"></a>
<a name="line680"></a>  // Clear the footer row.
<a name="line681"></a>  goog.dom.removeChildren(row);
<a name="line682"></a>
<a name="line683"></a>  // Populate the footer row with buttons for Today and None.
<a name="line684"></a>  var cell = this.dom_.createElement(&#39;td&#39;);
<a name="line685"></a>  cell.colSpan = 2;
<a name="line686"></a>  cell.className = goog.getCssName(this.getBaseCssClass(), &#39;today-cont&#39;);
<a name="line687"></a>
<a name="line688"></a>  /** @desc Label for button that selects the current date. */
<a name="line689"></a>  var MSG_DATEPICKER_TODAY_BUTTON_LABEL = goog.getMsg(&#39;Today&#39;);
<a name="line690"></a>  this.elToday_ = this.createButton_(cell, MSG_DATEPICKER_TODAY_BUTTON_LABEL,
<a name="line691"></a>                                     this.selectToday);
<a name="line692"></a>  row.appendChild(cell);
<a name="line693"></a>
<a name="line694"></a>  cell = this.dom_.createElement(&#39;td&#39;);
<a name="line695"></a>  cell.colSpan = 4;
<a name="line696"></a>  row.appendChild(cell);
<a name="line697"></a>
<a name="line698"></a>  cell = this.dom_.createElement(&#39;td&#39;);
<a name="line699"></a>  cell.colSpan = 2;
<a name="line700"></a>  cell.className = goog.getCssName(this.getBaseCssClass(), &#39;none-cont&#39;);
<a name="line701"></a>
<a name="line702"></a>  /** @desc Label for button that clears the selection. */
<a name="line703"></a>  var MSG_DATEPICKER_NONE = goog.getMsg(&#39;None&#39;);
<a name="line704"></a>  this.elNone_ = this.createButton_(cell, MSG_DATEPICKER_NONE, this.selectNone);
<a name="line705"></a>  row.appendChild(cell);
<a name="line706"></a>  this.updateTodayAndNone_();
<a name="line707"></a>};
<a name="line708"></a>
<a name="line709"></a>
<a name="line710"></a>/** @override */
<a name="line711"></a>goog.ui.DatePicker.prototype.decorateInternal = function(el) {
<a name="line712"></a>  goog.ui.DatePicker.superClass_.decorateInternal.call(this, el);
<a name="line713"></a>
<a name="line714"></a>  el.className = this.getBaseCssClass();
<a name="line715"></a>
<a name="line716"></a>  var table = this.dom_.createElement(&#39;table&#39;);
<a name="line717"></a>  var thead = this.dom_.createElement(&#39;thead&#39;);
<a name="line718"></a>  var tbody = this.dom_.createElement(&#39;tbody&#39;);
<a name="line719"></a>  var tfoot = this.dom_.createElement(&#39;tfoot&#39;);
<a name="line720"></a>
<a name="line721"></a>  goog.a11y.aria.setRole(tbody, &#39;grid&#39;);
<a name="line722"></a>  tbody.tabIndex = &#39;0&#39;;
<a name="line723"></a>
<a name="line724"></a>  // As per comment in colorpicker: table.tBodies and table.tFoot should not be
<a name="line725"></a>  // used because of a bug in Safari, hence using an instance variable
<a name="line726"></a>  this.tableBody_ = tbody;
<a name="line727"></a>  this.tableFoot_ = tfoot;
<a name="line728"></a>
<a name="line729"></a>  var row = this.dom_.createElement(&#39;tr&#39;);
<a name="line730"></a>  row.className = goog.getCssName(this.getBaseCssClass(), &#39;head&#39;);
<a name="line731"></a>  this.elNavRow_ = row;
<a name="line732"></a>  this.updateNavigationRow_();
<a name="line733"></a>
<a name="line734"></a>  thead.appendChild(row);
<a name="line735"></a>
<a name="line736"></a>  var cell;
<a name="line737"></a>  this.elTable_ = [];
<a name="line738"></a>  for (var i = 0; i &lt; 7; i++) {
<a name="line739"></a>    row = this.dom_.createElement(&#39;tr&#39;);
<a name="line740"></a>    this.elTable_[i] = [];
<a name="line741"></a>    for (var j = 0; j &lt; 8; j++) {
<a name="line742"></a>      cell = this.dom_.createElement(j == 0 || i == 0 ? &#39;th&#39; : &#39;td&#39;);
<a name="line743"></a>      if ((j == 0 || i == 0) &amp;&amp; j != i) {
<a name="line744"></a>        cell.className = (j == 0) ?
<a name="line745"></a>            goog.getCssName(this.getBaseCssClass(), &#39;week&#39;) :
<a name="line746"></a>            goog.getCssName(this.getBaseCssClass(), &#39;wday&#39;);
<a name="line747"></a>        goog.a11y.aria.setRole(cell, j == 0 ? &#39;rowheader&#39; : &#39;columnheader&#39;);
<a name="line748"></a>      }
<a name="line749"></a>      row.appendChild(cell);
<a name="line750"></a>      this.elTable_[i][j] = cell;
<a name="line751"></a>    }
<a name="line752"></a>    tbody.appendChild(row);
<a name="line753"></a>  }
<a name="line754"></a>
<a name="line755"></a>  row = this.dom_.createElement(&#39;tr&#39;);
<a name="line756"></a>  row.className = goog.getCssName(this.getBaseCssClass(), &#39;foot&#39;);
<a name="line757"></a>  this.elFootRow_ = row;
<a name="line758"></a>  this.updateFooterRow_();
<a name="line759"></a>  tfoot.appendChild(row);
<a name="line760"></a>
<a name="line761"></a>
<a name="line762"></a>  table.cellSpacing = &#39;0&#39;;
<a name="line763"></a>  table.cellPadding = &#39;0&#39;;
<a name="line764"></a>  table.appendChild(thead);
<a name="line765"></a>  table.appendChild(tbody);
<a name="line766"></a>  table.appendChild(tfoot);
<a name="line767"></a>  el.appendChild(table);
<a name="line768"></a>
<a name="line769"></a>  this.redrawWeekdays_();
<a name="line770"></a>  this.updateCalendarGrid_();
<a name="line771"></a>
<a name="line772"></a>  el.tabIndex = 0;
<a name="line773"></a>};
<a name="line774"></a>
<a name="line775"></a>
<a name="line776"></a>/** @override */
<a name="line777"></a>goog.ui.DatePicker.prototype.createDom = function() {
<a name="line778"></a>  goog.ui.DatePicker.superClass_.createDom.call(this);
<a name="line779"></a>  this.decorateInternal(this.getElement());
<a name="line780"></a>};
<a name="line781"></a>
<a name="line782"></a>
<a name="line783"></a>/** @override */
<a name="line784"></a>goog.ui.DatePicker.prototype.enterDocument = function() {
<a name="line785"></a>  goog.ui.DatePicker.superClass_.enterDocument.call(this);
<a name="line786"></a>
<a name="line787"></a>  var eh = this.getHandler();
<a name="line788"></a>  eh.listen(this.tableBody_, goog.events.EventType.CLICK,
<a name="line789"></a>      this.handleGridClick_);
<a name="line790"></a>  eh.listen(this.getKeyHandlerForElement_(this.getElement()),
<a name="line791"></a>      goog.events.KeyHandler.EventType.KEY, this.handleGridKeyPress_);
<a name="line792"></a>};
<a name="line793"></a>
<a name="line794"></a>
<a name="line795"></a>/** @override */
<a name="line796"></a>goog.ui.DatePicker.prototype.exitDocument = function() {
<a name="line797"></a>  goog.ui.DatePicker.superClass_.exitDocument.call(this);
<a name="line798"></a>  this.destroyMenu_();
<a name="line799"></a>  for (var uid in this.keyHandlers_) {
<a name="line800"></a>    this.keyHandlers_[uid].dispose();
<a name="line801"></a>  }
<a name="line802"></a>  this.keyHandlers_ = {};
<a name="line803"></a>};
<a name="line804"></a>
<a name="line805"></a>
<a name="line806"></a>/**
<a name="line807"></a> * @deprecated Use decorate instead.
<a name="line808"></a> */
<a name="line809"></a>goog.ui.DatePicker.prototype.create =
<a name="line810"></a>    goog.ui.DatePicker.prototype.decorate;
<a name="line811"></a>
<a name="line812"></a>
<a name="line813"></a>/** @override */
<a name="line814"></a>goog.ui.DatePicker.prototype.disposeInternal = function() {
<a name="line815"></a>  goog.ui.DatePicker.superClass_.disposeInternal.call(this);
<a name="line816"></a>
<a name="line817"></a>  this.elTable_ = null;
<a name="line818"></a>  this.tableBody_ = null;
<a name="line819"></a>  this.tableFoot_ = null;
<a name="line820"></a>  this.elNavRow_ = null;
<a name="line821"></a>  this.elFootRow_ = null;
<a name="line822"></a>  this.elMonth_ = null;
<a name="line823"></a>  this.elMonthYear_ = null;
<a name="line824"></a>  this.elYear_ = null;
<a name="line825"></a>  this.elToday_ = null;
<a name="line826"></a>  this.elNone_ = null;
<a name="line827"></a>};
<a name="line828"></a>
<a name="line829"></a>
<a name="line830"></a>/**
<a name="line831"></a> * Click handler for date grid.
<a name="line832"></a> *
<a name="line833"></a> * @param {goog.events.BrowserEvent} event Click event.
<a name="line834"></a> * @private
<a name="line835"></a> */
<a name="line836"></a>goog.ui.DatePicker.prototype.handleGridClick_ = function(event) {
<a name="line837"></a>  if (event.target.tagName == &#39;TD&#39;) {
<a name="line838"></a>    // colIndex/rowIndex is broken in Safari, find position by looping
<a name="line839"></a>    var el, x = -2, y = -2; // first col/row is for weekday/weeknum
<a name="line840"></a>    for (el = event.target; el; el = el.previousSibling, x++) {}
<a name="line841"></a>    for (el = event.target.parentNode; el; el = el.previousSibling, y++) {}
<a name="line842"></a>    var obj = this.grid_[y][x];
<a name="line843"></a>    this.setDate(obj.clone());
<a name="line844"></a>  }
<a name="line845"></a>};
<a name="line846"></a>
<a name="line847"></a>
<a name="line848"></a>/**
<a name="line849"></a> * Keypress handler for date grid.
<a name="line850"></a> *
<a name="line851"></a> * @param {goog.events.BrowserEvent} event Keypress event.
<a name="line852"></a> * @private
<a name="line853"></a> */
<a name="line854"></a>goog.ui.DatePicker.prototype.handleGridKeyPress_ = function(event) {
<a name="line855"></a>  var months, days;
<a name="line856"></a>  switch (event.keyCode) {
<a name="line857"></a>    case 33: // Page up
<a name="line858"></a>      event.preventDefault();
<a name="line859"></a>      months = -1;
<a name="line860"></a>      break;
<a name="line861"></a>    case 34: // Page down
<a name="line862"></a>      event.preventDefault();
<a name="line863"></a>      months = 1;
<a name="line864"></a>      break;
<a name="line865"></a>    case 37: // Left
<a name="line866"></a>      event.preventDefault();
<a name="line867"></a>      days = -1;
<a name="line868"></a>      break;
<a name="line869"></a>    case 39: // Right
<a name="line870"></a>      event.preventDefault();
<a name="line871"></a>      days = 1;
<a name="line872"></a>      break;
<a name="line873"></a>    case 38: // Down
<a name="line874"></a>      event.preventDefault();
<a name="line875"></a>      days = -7;
<a name="line876"></a>      break;
<a name="line877"></a>    case 40: // Up
<a name="line878"></a>      event.preventDefault();
<a name="line879"></a>      days = 7;
<a name="line880"></a>      break;
<a name="line881"></a>    case 36: // Home
<a name="line882"></a>      event.preventDefault();
<a name="line883"></a>      this.selectToday();
<a name="line884"></a>    case 46: // Delete
<a name="line885"></a>      event.preventDefault();
<a name="line886"></a>      this.selectNone();
<a name="line887"></a>    default:
<a name="line888"></a>      return;
<a name="line889"></a>  }
<a name="line890"></a>  var date;
<a name="line891"></a>  if (this.date_) {
<a name="line892"></a>    date = this.date_.clone();
<a name="line893"></a>    date.add(new goog.date.Interval(0, months, days));
<a name="line894"></a>  } else {
<a name="line895"></a>    date = this.activeMonth_.clone();
<a name="line896"></a>    date.setDate(1);
<a name="line897"></a>  }
<a name="line898"></a>  this.setDate(date);
<a name="line899"></a>};
<a name="line900"></a>
<a name="line901"></a>
<a name="line902"></a>/**
<a name="line903"></a> * Click handler for month button. Opens month selection menu.
<a name="line904"></a> *
<a name="line905"></a> * @param {goog.events.BrowserEvent} event Click event.
<a name="line906"></a> * @private
<a name="line907"></a> */
<a name="line908"></a>goog.ui.DatePicker.prototype.showMonthMenu_ = function(event) {
<a name="line909"></a>  event.stopPropagation();
<a name="line910"></a>
<a name="line911"></a>  var list = [];
<a name="line912"></a>  for (var i = 0; i &lt; 12; i++) {
<a name="line913"></a>    list.push(this.symbols_.STANDALONEMONTHS[i]);
<a name="line914"></a>  }
<a name="line915"></a>  this.createMenu_(this.elMonth_, list, this.handleMonthMenuClick_,
<a name="line916"></a>      this.symbols_.STANDALONEMONTHS[this.activeMonth_.getMonth()]);
<a name="line917"></a>};
<a name="line918"></a>
<a name="line919"></a>
<a name="line920"></a>/**
<a name="line921"></a> * Click handler for year button. Opens year selection menu.
<a name="line922"></a> *
<a name="line923"></a> * @param {goog.events.BrowserEvent} event Click event.
<a name="line924"></a> * @private
<a name="line925"></a> */
<a name="line926"></a>goog.ui.DatePicker.prototype.showYearMenu_ = function(event) {
<a name="line927"></a>  event.stopPropagation();
<a name="line928"></a>
<a name="line929"></a>  var list = [];
<a name="line930"></a>  var year = this.activeMonth_.getFullYear() - 5;
<a name="line931"></a>  for (var i = 0; i &lt; 11; i++) {
<a name="line932"></a>    list.push(String(year + i));
<a name="line933"></a>  }
<a name="line934"></a>  this.createMenu_(this.elYear_, list, this.handleYearMenuClick_,
<a name="line935"></a>                   String(this.activeMonth_.getFullYear()));
<a name="line936"></a>};
<a name="line937"></a>
<a name="line938"></a>
<a name="line939"></a>/**
<a name="line940"></a> * Call back function for month menu.
<a name="line941"></a> *
<a name="line942"></a> * @param {Element} target Selected item.
<a name="line943"></a> * @private
<a name="line944"></a> */
<a name="line945"></a>goog.ui.DatePicker.prototype.handleMonthMenuClick_ = function(target) {
<a name="line946"></a>  var el = target;
<a name="line947"></a>  for (var i = -1; el; el = goog.dom.getPreviousElementSibling(el), i++) {}
<a name="line948"></a>
<a name="line949"></a>  this.activeMonth_.setMonth(i);
<a name="line950"></a>  this.updateCalendarGrid_();
<a name="line951"></a>
<a name="line952"></a>  if (this.elMonth_.focus) {
<a name="line953"></a>    this.elMonth_.focus();
<a name="line954"></a>  }
<a name="line955"></a>};
<a name="line956"></a>
<a name="line957"></a>
<a name="line958"></a>/**
<a name="line959"></a> * Call back function for year menu.
<a name="line960"></a> *
<a name="line961"></a> * @param {Element} target Selected item.
<a name="line962"></a> * @private
<a name="line963"></a> */
<a name="line964"></a>goog.ui.DatePicker.prototype.handleYearMenuClick_ = function(target) {
<a name="line965"></a>  if (target.firstChild.nodeType == goog.dom.NodeType.TEXT) {
<a name="line966"></a>    this.activeMonth_.setFullYear(Number(target.firstChild.nodeValue));
<a name="line967"></a>    this.updateCalendarGrid_();
<a name="line968"></a>  }
<a name="line969"></a>
<a name="line970"></a>  this.elYear_.focus();
<a name="line971"></a>};
<a name="line972"></a>
<a name="line973"></a>
<a name="line974"></a>/**
<a name="line975"></a> * Support function for menu creation.
<a name="line976"></a> *
<a name="line977"></a> * @param {Element} srcEl Button to create menu for.
<a name="line978"></a> * @param {Array.&lt;string&gt;} items List of items to populate menu with.
<a name="line979"></a> * @param {Function} method Call back method.
<a name="line980"></a> * @param {string} selected Item to mark as selected in menu.
<a name="line981"></a> * @private
<a name="line982"></a> */
<a name="line983"></a>goog.ui.DatePicker.prototype.createMenu_ = function(srcEl, items, method,
<a name="line984"></a>                                                    selected) {
<a name="line985"></a>  this.destroyMenu_();
<a name="line986"></a>
<a name="line987"></a>  var el = this.dom_.createElement(&#39;div&#39;);
<a name="line988"></a>  el.className = goog.getCssName(this.getBaseCssClass(), &#39;menu&#39;);
<a name="line989"></a>
<a name="line990"></a>  this.menuSelected_ = null;
<a name="line991"></a>
<a name="line992"></a>  var ul = this.dom_.createElement(&#39;ul&#39;);
<a name="line993"></a>  for (var i = 0; i &lt; items.length; i++) {
<a name="line994"></a>    var li = this.dom_.createDom(&#39;li&#39;, null, items[i]);
<a name="line995"></a>    if (items[i] == selected) {
<a name="line996"></a>      this.menuSelected_ = li;
<a name="line997"></a>    }
<a name="line998"></a>    ul.appendChild(li);
<a name="line999"></a>  }
<a name="line1000"></a>  el.appendChild(ul);
<a name="line1001"></a>  el.style.left = srcEl.offsetLeft + srcEl.parentNode.offsetLeft + &#39;px&#39;;
<a name="line1002"></a>  el.style.top = srcEl.offsetTop + &#39;px&#39;;
<a name="line1003"></a>  el.style.width = srcEl.clientWidth + &#39;px&#39;;
<a name="line1004"></a>  this.elMonth_.parentNode.appendChild(el);
<a name="line1005"></a>
<a name="line1006"></a>  this.menu_ = el;
<a name="line1007"></a>  if (!this.menuSelected_) {
<a name="line1008"></a>    this.menuSelected_ = ul.firstChild;
<a name="line1009"></a>  }
<a name="line1010"></a>  this.menuSelected_.className =
<a name="line1011"></a>      goog.getCssName(this.getBaseCssClass(), &#39;menu-selected&#39;);
<a name="line1012"></a>  this.menuCallback_ = method;
<a name="line1013"></a>
<a name="line1014"></a>  var eh = this.getHandler();
<a name="line1015"></a>  eh.listen(this.menu_, goog.events.EventType.CLICK, this.handleMenuClick_);
<a name="line1016"></a>  eh.listen(this.getKeyHandlerForElement_(this.menu_),
<a name="line1017"></a>      goog.events.KeyHandler.EventType.KEY, this.handleMenuKeyPress_);
<a name="line1018"></a>  eh.listen(this.dom_.getDocument(), goog.events.EventType.CLICK,
<a name="line1019"></a>      this.destroyMenu_);
<a name="line1020"></a>  el.tabIndex = 0;
<a name="line1021"></a>  el.focus();
<a name="line1022"></a>};
<a name="line1023"></a>
<a name="line1024"></a>
<a name="line1025"></a>/**
<a name="line1026"></a> * Click handler for menu.
<a name="line1027"></a> *
<a name="line1028"></a> * @param {goog.events.BrowserEvent} event Click event.
<a name="line1029"></a> * @private
<a name="line1030"></a> */
<a name="line1031"></a>goog.ui.DatePicker.prototype.handleMenuClick_ = function(event) {
<a name="line1032"></a>  event.stopPropagation();
<a name="line1033"></a>
<a name="line1034"></a>  this.destroyMenu_();
<a name="line1035"></a>  if (this.menuCallback_) {
<a name="line1036"></a>    this.menuCallback_(event.target);
<a name="line1037"></a>  }
<a name="line1038"></a>};
<a name="line1039"></a>
<a name="line1040"></a>
<a name="line1041"></a>/**
<a name="line1042"></a> * Keypress handler for menu.
<a name="line1043"></a> *
<a name="line1044"></a> * @param {goog.events.BrowserEvent} event Keypress event.
<a name="line1045"></a> * @private
<a name="line1046"></a> */
<a name="line1047"></a>goog.ui.DatePicker.prototype.handleMenuKeyPress_ = function(event) {
<a name="line1048"></a>  // Prevent the grid keypress handler from catching the keypress event.
<a name="line1049"></a>  event.stopPropagation();
<a name="line1050"></a>
<a name="line1051"></a>  var el;
<a name="line1052"></a>  var menuSelected = this.menuSelected_;
<a name="line1053"></a>  switch (event.keyCode) {
<a name="line1054"></a>    case 35: // End
<a name="line1055"></a>      event.preventDefault();
<a name="line1056"></a>      el = menuSelected.parentNode.lastChild;
<a name="line1057"></a>      break;
<a name="line1058"></a>    case 36: // Home
<a name="line1059"></a>      event.preventDefault();
<a name="line1060"></a>      el = menuSelected.parentNode.firstChild;
<a name="line1061"></a>      break;
<a name="line1062"></a>    case 38: // Up
<a name="line1063"></a>      event.preventDefault();
<a name="line1064"></a>      el = menuSelected.previousSibling;
<a name="line1065"></a>      break;
<a name="line1066"></a>    case 40: // Down
<a name="line1067"></a>      event.preventDefault();
<a name="line1068"></a>      el = menuSelected.nextSibling;
<a name="line1069"></a>      break;
<a name="line1070"></a>    case 13: // Enter
<a name="line1071"></a>    case 9: // Tab
<a name="line1072"></a>    case 0: // Space
<a name="line1073"></a>      event.preventDefault();
<a name="line1074"></a>      this.destroyMenu_();
<a name="line1075"></a>      this.menuCallback_(menuSelected);
<a name="line1076"></a>      break;
<a name="line1077"></a>  }
<a name="line1078"></a>  if (el &amp;&amp; el != menuSelected) {
<a name="line1079"></a>    menuSelected.className = &#39;&#39;;
<a name="line1080"></a>    el.className = goog.getCssName(this.getBaseCssClass(), &#39;menu-selected&#39;);
<a name="line1081"></a>    this.menuSelected_ = el;
<a name="line1082"></a>  }
<a name="line1083"></a>};
<a name="line1084"></a>
<a name="line1085"></a>
<a name="line1086"></a>/**
<a name="line1087"></a> * Support function for menu destruction.
<a name="line1088"></a> * @private
<a name="line1089"></a> */
<a name="line1090"></a>goog.ui.DatePicker.prototype.destroyMenu_ = function() {
<a name="line1091"></a>  if (this.menu_) {
<a name="line1092"></a>    var eh = this.getHandler();
<a name="line1093"></a>    eh.unlisten(this.menu_, goog.events.EventType.CLICK, this.handleMenuClick_);
<a name="line1094"></a>    eh.unlisten(this.getKeyHandlerForElement_(this.menu_),
<a name="line1095"></a>        goog.events.KeyHandler.EventType.KEY, this.handleMenuKeyPress_);
<a name="line1096"></a>    eh.unlisten(this.dom_.getDocument(), goog.events.EventType.CLICK,
<a name="line1097"></a>        this.destroyMenu_);
<a name="line1098"></a>    goog.dom.removeNode(this.menu_);
<a name="line1099"></a>    delete this.menu_;
<a name="line1100"></a>  }
<a name="line1101"></a>};
<a name="line1102"></a>
<a name="line1103"></a>
<a name="line1104"></a>/**
<a name="line1105"></a> * Support function for button creation.
<a name="line1106"></a> *
<a name="line1107"></a> * @param {Element} parentNode Container the button should be added to.
<a name="line1108"></a> * @param {string} label Button label.
<a name="line1109"></a> * @param {Function} method Event handler.
<a name="line1110"></a> * @param {string=} opt_className Class name for button, which will be used
<a name="line1111"></a> *    in addition to &quot;goog-date-picker-btn&quot;.
<a name="line1112"></a> * @private
<a name="line1113"></a> * @return {Element} The created button element.
<a name="line1114"></a> */
<a name="line1115"></a>goog.ui.DatePicker.prototype.createButton_ = function(parentNode, label,
<a name="line1116"></a>                                                      method, opt_className) {
<a name="line1117"></a>  var classes = [goog.getCssName(this.getBaseCssClass(), &#39;btn&#39;)];
<a name="line1118"></a>  if (opt_className) {
<a name="line1119"></a>    classes.push(opt_className);
<a name="line1120"></a>  }
<a name="line1121"></a>  var el = this.dom_.createElement(&#39;button&#39;);
<a name="line1122"></a>  el.className = classes.join(&#39; &#39;);
<a name="line1123"></a>  el.appendChild(this.dom_.createTextNode(label));
<a name="line1124"></a>  parentNode.appendChild(el);
<a name="line1125"></a>  this.getHandler().listen(el, goog.events.EventType.CLICK, function(e) {
<a name="line1126"></a>    // Since this is a button, the default action is to submit a form if the
<a name="line1127"></a>    // node is added inside a form.  Prevent this.
<a name="line1128"></a>    e.preventDefault();
<a name="line1129"></a>    method.call(this, e);
<a name="line1130"></a>  });
<a name="line1131"></a>
<a name="line1132"></a>  return el;
<a name="line1133"></a>};
<a name="line1134"></a>
<a name="line1135"></a>
<a name="line1136"></a>/**
<a name="line1137"></a> * Determines the dates/weekdays for the current month and builds an in memory
<a name="line1138"></a> * representation of the calendar.
<a name="line1139"></a> *
<a name="line1140"></a> * @private
<a name="line1141"></a> */
<a name="line1142"></a>goog.ui.DatePicker.prototype.updateCalendarGrid_ = function() {
<a name="line1143"></a>  if (!this.getElement()) {
<a name="line1144"></a>    return;
<a name="line1145"></a>  }
<a name="line1146"></a>
<a name="line1147"></a>  var date = this.activeMonth_.clone();
<a name="line1148"></a>  date.setDate(1);
<a name="line1149"></a>
<a name="line1150"></a>  // Show year name of select month
<a name="line1151"></a>  if (this.elMonthYear_) {
<a name="line1152"></a>    goog.dom.setTextContent(this.elMonthYear_,
<a name="line1153"></a>        goog.date.formatMonthAndYear(
<a name="line1154"></a>            this.symbols_.STANDALONEMONTHS[date.getMonth()],
<a name="line1155"></a>            date.getFullYear()));
<a name="line1156"></a>  }
<a name="line1157"></a>  if (this.elMonth_) {
<a name="line1158"></a>    goog.dom.setTextContent(this.elMonth_,
<a name="line1159"></a>        this.symbols_.STANDALONEMONTHS[date.getMonth()]);
<a name="line1160"></a>  }
<a name="line1161"></a>  if (this.elYear_) {
<a name="line1162"></a>    goog.dom.setTextContent(this.elYear_, String(date.getFullYear()));
<a name="line1163"></a>  }
<a name="line1164"></a>
<a name="line1165"></a>  var wday = date.getWeekday();
<a name="line1166"></a>  var days = date.getNumberOfDaysInMonth();
<a name="line1167"></a>
<a name="line1168"></a>  // Determine how many days to show for previous month
<a name="line1169"></a>  date.add(new goog.date.Interval(goog.date.Interval.MONTHS, -1));
<a name="line1170"></a>  date.setDate(date.getNumberOfDaysInMonth() - (wday - 1));
<a name="line1171"></a>
<a name="line1172"></a>  if (this.showFixedNumWeeks_ &amp;&amp; !this.extraWeekAtEnd_ &amp;&amp; days + wday &lt; 33) {
<a name="line1173"></a>    date.add(new goog.date.Interval(goog.date.Interval.DAYS, -7));
<a name="line1174"></a>  }
<a name="line1175"></a>
<a name="line1176"></a>  // Create weekday/day grid
<a name="line1177"></a>  var dayInterval = new goog.date.Interval(goog.date.Interval.DAYS, 1);
<a name="line1178"></a>  this.grid_ = [];
<a name="line1179"></a>  for (var y = 0; y &lt; 6; y++) { // Weeks
<a name="line1180"></a>    this.grid_[y] = [];
<a name="line1181"></a>    for (var x = 0; x &lt; 7; x++) { // Weekdays
<a name="line1182"></a>      this.grid_[y][x] = date.clone();
<a name="line1183"></a>      date.add(dayInterval);
<a name="line1184"></a>    }
<a name="line1185"></a>  }
<a name="line1186"></a>
<a name="line1187"></a>  this.redrawCalendarGrid_();
<a name="line1188"></a>};
<a name="line1189"></a>
<a name="line1190"></a>
<a name="line1191"></a>/**
<a name="line1192"></a> * Draws calendar view from in memory representation and applies class names
<a name="line1193"></a> * depending on the selection, weekday and whatever the day belongs to the
<a name="line1194"></a> * active month or not.
<a name="line1195"></a> * @private
<a name="line1196"></a> */
<a name="line1197"></a>goog.ui.DatePicker.prototype.redrawCalendarGrid_ = function() {
<a name="line1198"></a>  if (!this.getElement()) {
<a name="line1199"></a>    return;
<a name="line1200"></a>  }
<a name="line1201"></a>
<a name="line1202"></a>  var month = this.activeMonth_.getMonth();
<a name="line1203"></a>  var today = new goog.date.Date();
<a name="line1204"></a>  var todayYear = today.getFullYear();
<a name="line1205"></a>  var todayMonth = today.getMonth();
<a name="line1206"></a>  var todayDate = today.getDate();
<a name="line1207"></a>
<a name="line1208"></a>  // Draw calendar week by week, a worst case month has six weeks.
<a name="line1209"></a>  for (var y = 0; y &lt; 6; y++) {
<a name="line1210"></a>
<a name="line1211"></a>    // Draw week number, if enabled
<a name="line1212"></a>    if (this.showWeekNum_) {
<a name="line1213"></a>      goog.dom.setTextContent(this.elTable_[y + 1][0],
<a name="line1214"></a>                              this.grid_[y][0].getWeekNumber());
<a name="line1215"></a>      goog.dom.classes.set(this.elTable_[y + 1][0],
<a name="line1216"></a>                           goog.getCssName(this.getBaseCssClass(), &#39;week&#39;));
<a name="line1217"></a>    } else {
<a name="line1218"></a>      goog.dom.setTextContent(this.elTable_[y + 1][0], &#39;&#39;);
<a name="line1219"></a>      goog.dom.classes.set(this.elTable_[y + 1][0], &#39;&#39;);
<a name="line1220"></a>    }
<a name="line1221"></a>
<a name="line1222"></a>    for (var x = 0; x &lt; 7; x++) {
<a name="line1223"></a>      var o = this.grid_[y][x];
<a name="line1224"></a>      var el = this.elTable_[y + 1][x + 1];
<a name="line1225"></a>
<a name="line1226"></a>      // Assign a unique element id (required for setting the active descendant
<a name="line1227"></a>      // ARIA role) unless already set.
<a name="line1228"></a>      if (!el.id) {
<a name="line1229"></a>        el.id = this.cellIdGenerator_.getNextUniqueId();
<a name="line1230"></a>      }
<a name="line1231"></a>      goog.asserts.assert(el, &#39;The table DOM element cannot be null.&#39;);
<a name="line1232"></a>      goog.a11y.aria.setRole(el, &#39;gridcell&#39;);
<a name="line1233"></a>      var classes = [goog.getCssName(this.getBaseCssClass(), &#39;date&#39;)];
<a name="line1234"></a>      if (this.showOtherMonths_ || o.getMonth() == month) {
<a name="line1235"></a>        // Date belongs to previous or next month
<a name="line1236"></a>        if (o.getMonth() != month) {
<a name="line1237"></a>          classes.push(goog.getCssName(this.getBaseCssClass(), &#39;other-month&#39;));
<a name="line1238"></a>        }
<a name="line1239"></a>
<a name="line1240"></a>        // Apply styles set by setWeekdayClass
<a name="line1241"></a>        var wday = (x + this.activeMonth_.getFirstDayOfWeek() + 7) % 7;
<a name="line1242"></a>        if (this.wdayStyles_[wday]) {
<a name="line1243"></a>          classes.push(this.wdayStyles_[wday]);
<a name="line1244"></a>        }
<a name="line1245"></a>
<a name="line1246"></a>        // Current date
<a name="line1247"></a>        if (o.getDate() == todayDate &amp;&amp; o.getMonth() == todayMonth &amp;&amp;
<a name="line1248"></a>            o.getFullYear() == todayYear) {
<a name="line1249"></a>          classes.push(goog.getCssName(this.getBaseCssClass(), &#39;today&#39;));
<a name="line1250"></a>        }
<a name="line1251"></a>
<a name="line1252"></a>        // Selected date
<a name="line1253"></a>        if (this.date_ &amp;&amp; o.getDate() == this.date_.getDate() &amp;&amp;
<a name="line1254"></a>            o.getMonth() == this.date_.getMonth() &amp;&amp;
<a name="line1255"></a>            o.getFullYear() == this.date_.getFullYear()) {
<a name="line1256"></a>          classes.push(goog.getCssName(this.getBaseCssClass(), &#39;selected&#39;));
<a name="line1257"></a>          goog.asserts.assert(this.tableBody_,
<a name="line1258"></a>              &#39;The table body DOM element cannot be null&#39;);
<a name="line1259"></a>          goog.a11y.aria.setState(this.tableBody_, &#39;activedescendant&#39;, el.id);
<a name="line1260"></a>        }
<a name="line1261"></a>
<a name="line1262"></a>        // Custom decorator
<a name="line1263"></a>        if (this.decoratorFunction_) {
<a name="line1264"></a>          var customClass = this.decoratorFunction_(o);
<a name="line1265"></a>          if (customClass) {
<a name="line1266"></a>            classes.push(customClass);
<a name="line1267"></a>          }
<a name="line1268"></a>        }
<a name="line1269"></a>
<a name="line1270"></a>        // Set cell text to the date and apply classes.
<a name="line1271"></a>        goog.dom.setTextContent(el, o.getDate());
<a name="line1272"></a>        // Date belongs to previous or next month and showOtherMonths is false,
<a name="line1273"></a>        // clear text and classes.
<a name="line1274"></a>      } else {
<a name="line1275"></a>        goog.dom.setTextContent(el, &#39;&#39;);
<a name="line1276"></a>      }
<a name="line1277"></a>      goog.dom.classes.set(el, classes.join(&#39; &#39;));
<a name="line1278"></a>    }
<a name="line1279"></a>
<a name="line1280"></a>    // Hide the either the last one or last two weeks if they contain no days
<a name="line1281"></a>    // from the active month and the showFixedNumWeeks is false. The first four
<a name="line1282"></a>    // weeks are always shown as no month has less than 28 days).
<a name="line1283"></a>    if (y &gt;= 4) {
<a name="line1284"></a>      goog.style.showElement(this.elTable_[y + 1][0].parentNode,
<a name="line1285"></a>                             this.grid_[y][0].getMonth() == month ||
<a name="line1286"></a>                                 this.showFixedNumWeeks_);
<a name="line1287"></a>    }
<a name="line1288"></a>  }
<a name="line1289"></a>};
<a name="line1290"></a>
<a name="line1291"></a>
<a name="line1292"></a>/**
<a name="line1293"></a> * Draw weekday names, if enabled. Start with whatever day has been set as the
<a name="line1294"></a> * first day of week.
<a name="line1295"></a> * @private
<a name="line1296"></a> */
<a name="line1297"></a>goog.ui.DatePicker.prototype.redrawWeekdays_ = function() {
<a name="line1298"></a>  if (!this.getElement()) {
<a name="line1299"></a>    return;
<a name="line1300"></a>  }
<a name="line1301"></a>  if (this.showWeekdays_) {
<a name="line1302"></a>    for (var x = 0; x &lt; 7; x++) {
<a name="line1303"></a>      var el = this.elTable_[0][x + 1];
<a name="line1304"></a>      var wday = (x + this.activeMonth_.getFirstDayOfWeek() + 7) % 7;
<a name="line1305"></a>      goog.dom.setTextContent(el, this.wdayNames_[(wday + 1) % 7]);
<a name="line1306"></a>    }
<a name="line1307"></a>  }
<a name="line1308"></a>  goog.style.showElement(this.elTable_[0][0].parentNode, this.showWeekdays_);
<a name="line1309"></a>};
<a name="line1310"></a>
<a name="line1311"></a>
<a name="line1312"></a>/**
<a name="line1313"></a> * Returns the key handler for an element and caches it so that it can be
<a name="line1314"></a> * retrieved at a later point.
<a name="line1315"></a> * @param {Element} el The element to get the key handler for.
<a name="line1316"></a> * @return {goog.events.KeyHandler} The key handler for the element.
<a name="line1317"></a> * @private
<a name="line1318"></a> */
<a name="line1319"></a>goog.ui.DatePicker.prototype.getKeyHandlerForElement_ = function(el) {
<a name="line1320"></a>  var uid = goog.getUid(el);
<a name="line1321"></a>  if (!(uid in this.keyHandlers_)) {
<a name="line1322"></a>    this.keyHandlers_[uid] = new goog.events.KeyHandler(el);
<a name="line1323"></a>  }
<a name="line1324"></a>  return this.keyHandlers_[uid];
<a name="line1325"></a>};
<a name="line1326"></a>
<a name="line1327"></a>
<a name="line1328"></a>
<a name="line1329"></a>/**
<a name="line1330"></a> * Object representing a date picker event.
<a name="line1331"></a> *
<a name="line1332"></a> * @param {string} type Event type.
<a name="line1333"></a> * @param {goog.ui.DatePicker} target Date picker initiating event.
<a name="line1334"></a> * @param {goog.date.Date} date Selected date.
<a name="line1335"></a> * @constructor
<a name="line1336"></a> * @extends {goog.events.Event}
<a name="line1337"></a> */
<a name="line1338"></a>goog.ui.DatePickerEvent = function(type, target, date) {
<a name="line1339"></a>  goog.events.Event.call(this, type, target);
<a name="line1340"></a>
<a name="line1341"></a>  /**
<a name="line1342"></a>   * The selected date
<a name="line1343"></a>   * @type {goog.date.Date}
<a name="line1344"></a>   */
<a name="line1345"></a>  this.date = date;
<a name="line1346"></a>};
<a name="line1347"></a>goog.inherits(goog.ui.DatePickerEvent, goog.events.Event);
</pre>


</body>
</html>
